package consul

import (
	"fmt"
	capi "github.com/hashicorp/consul/api"
)

func ConSulRegisterService(consul_address, scheme, id, name, tags, address string, port int) {
	client, err := capi.NewClient(&capi.Config{
		Address: consul_address,
		Scheme:  scheme,
	})
	if err != nil {
		panic(err)
	}

	// Get a handle to the KV API
	ag := client.Agent()
	err = ag.ServiceRegister(&capi.AgentServiceRegistration{
		ID:      id,
		Name:    name,
		Tags:    []string{tags},
		Port:    port,
		Address: address,
	})
	fmt.Println(err)
}
